<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  
  <title>赵天恩博客</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="赵天恩博客">
<meta property="og:type" content="website">
<meta property="og:title" content="赵天恩博客">
<meta property="og:url" content="http://zhaotianen.github.io/index.html">
<meta property="og:site_name" content="赵天恩博客">
<meta property="og:description" content="赵天恩博客">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="赵天恩博客">
<meta name="twitter:description" content="赵天恩博客">
  
    <link rel="alternative" href="/atom.xml" title="赵天恩博客" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
      <link rel="stylesheet" href="//cdn.bootcss.com/animate.css/3.5.0/animate.min.css">
  
  
  
      <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
      <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">
  
  <link rel="stylesheet" href="/css/style.css">
  
      <style> .article { opacity: 0;} </style>
  
  <link rel="stylesheet" href="/font-awesome/css/font-awesome.min.css">
  <link rel="apple-touch-icon" href="/apple-touch-icon.png">
  
    
    
  
  
    <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  
  <script src="//cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script>
  <script>
      var yiliaConfig = {
          fancybox: true,
          animate: true,
          isHome: true,
          isPost: false,
          isArchive: false,
          isTag: false,
          isCategory: false,
          open_in_new: true,
      }
  </script>

  
      <script>
          yiliaConfig.rootUrl = "/";
      </script>
  

  

  
</head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            <img src="/img/avatar.png" class="animated zoomIn">
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/">赵天恩</a></h1>
        </hgroup>

        
        <p class="header-subtitle">赵天恩博客</p>
        
                


        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                        <div class="icon-wrap icon-me hide" data-idx="3">
                            <div class="user"></div>
                            <div class="shoulder"></div>
                        </div>
                        
                    </div>
                    
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>菜单</li>
                        <li>标签</li>
                        
                        <li>友情链接</li>
                        
                        
                        <li>关于我</li>
                        
                    </ul>
                </div>
            </div>
        

        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/">主页</a></li>
                        
                            <li><a href="/archives/">所有文章</a></li>
                        
                            <li><a href="/2017/09/01/about/">关于我</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <li id="Email"><a class="Email" target="_blank" href="mailto:ztelovecly@gmail.com" title="Email"></a></li>
                            
                                <li id="GitHub"><a class="GitHub" target="_blank" href="https://github.com/zhaotianen" title="GitHub"></a></li>
                            
                                <li id="QQ"><a class="QQ" target="_blank" href="tencent://message/?uin=909442787&Site=&menu=yes" title="QQ"></a></li>
                            
                                <li id="微信"><a class="微信" target="_blank" href="/zte_cly" title="微信"></a></li>
                            
                        </ul>
                    </nav>
                </section>
                
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        <a href="/tags/Android/" style="font-size: 16.67px;">Android</a> <a href="/tags/Android系统源代码情景分析/" style="font-size: 10px;">Android系统源代码情景分析</a> <a href="/tags/Git/" style="font-size: 13.33px;">Git</a> <a href="/tags/Github/" style="font-size: 13.33px;">Github</a> <a href="/tags/Hadoop权威指南/" style="font-size: 10px;">Hadoop权威指南</a> <a href="/tags/HashMap/" style="font-size: 10px;">HashMap</a> <a href="/tags/Hexo/" style="font-size: 13.33px;">Hexo</a> <a href="/tags/IntelliJ-IDEA/" style="font-size: 13.33px;">IntelliJ IDEA</a> <a href="/tags/Java并发编程-核心方法与框架/" style="font-size: 10px;">Java并发编程-核心方法与框架</a> <a href="/tags/Java核心技术-卷1/" style="font-size: 10px;">Java核心技术-卷1</a> <a href="/tags/Java核心技术-卷2/" style="font-size: 10px;">Java核心技术-卷2</a> <a href="/tags/Linux私房菜-基础学习篇/" style="font-size: 10px;">Linux私房菜-基础学习篇</a> <a href="/tags/Node-js/" style="font-size: 13.33px;">Node.js</a> <a href="/tags/RBAC/" style="font-size: 10px;">RBAC</a> <a href="/tags/android/" style="font-size: 16.67px;">android</a> <a href="/tags/java/" style="font-size: 20px;">java</a> <a href="/tags/jvm/" style="font-size: 10px;">jvm</a> <a href="/tags/linux/" style="font-size: 10px;">linux</a> <a href="/tags/mac/" style="font-size: 10px;">mac</a> <a href="/tags/maven/" style="font-size: 10px;">maven</a> <a href="/tags/mysql/" style="font-size: 10px;">mysql</a> <a href="/tags/springBoot/" style="font-size: 10px;">springBoot</a> <a href="/tags/关于我/" style="font-size: 10px;">关于我</a> <a href="/tags/大数据/" style="font-size: 13.33px;">大数据</a> <a href="/tags/大数据之路/" style="font-size: 10px;">大数据之路</a> <a href="/tags/实践Java虚拟机-JVM故障诊断与性能优化/" style="font-size: 10px;">实践Java虚拟机-JVM故障诊断与性能优化</a> <a href="/tags/架构/" style="font-size: 10px;">架构</a> <a href="/tags/架构即未来/" style="font-size: 10px;">架构即未来</a> <a href="/tags/深入实践SpringBoot/" style="font-size: 10px;">深入实践SpringBoot</a> <a href="/tags/深入解析Android5-0系统/" style="font-size: 10px;">深入解析Android5.0系统</a> <a href="/tags/第一行代码/" style="font-size: 10px;">第一行代码</a> <a href="/tags/轻量级JavaEE企业应用实践/" style="font-size: 10px;">轻量级JavaEE企业应用实践</a> <a href="/tags/重构/" style="font-size: 10px;">重构</a> <a href="/tags/高性能MySql/" style="font-size: 10px;">高性能MySql</a>
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="https://hexo.io">Hexo</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="https://pages.github.com/">GitHub</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">专注于Java</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">赵天恩</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                <img src="/img/avatar.png" class="animated zoomIn">
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="回到主页">赵天恩</a></h1>
            </hgroup>
            
            <p class="header-subtitle">赵天恩博客</p>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/">主页</a></li>
                
                    <li><a href="/archives/">所有文章</a></li>
                
                    <li><a href="/2017/09/01/about/">关于我</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                        <ul class="social">
                            
                                <li id="Email"><a class="Email" target="_blank" href="mailto:ztelovecly@gmail.com" title="Email"></a></li>
                            
                                <li id="GitHub"><a class="GitHub" target="_blank" href="https://github.com/zhaotianen" title="GitHub"></a></li>
                            
                                <li id="QQ"><a class="QQ" target="_blank" href="tencent://message/?uin=909442787&Site=&menu=yes" title="QQ"></a></li>
                            
                                <li id="微信"><a class="微信" target="_blank" href="/zte_cly" title="微信"></a></li>
                            
                        </ul>
            </nav>
        </header>                
    </div>
</nav>
      <div class="body-wrap">
  
    <article id="post-java/HashMap浅析（1.8.0_60版）" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2017/09/07/java/HashMap浅析（1.8.0_60版）/" class="article-date">
      <time datetime="2017-09-07T14:51:19.000Z" itemprop="datePublished">2017-09-07</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2017/09/07/java/HashMap浅析（1.8.0_60版）/">HashMap浅析（1.8.0_60版）</a>
    </h1>
  

      </header>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <h1 id="HashMap浅析（1-8-0-60版）"><a href="#HashMap浅析（1-8-0-60版）" class="headerlink" title="HashMap浅析（1.8.0_60版）"></a>HashMap浅析（1.8.0_60版）</h1><pre><code>写在最前：
HashMap在JDK 1.8中，相比JDK 1.7做了较多的改动。
HashMap的数据结构（数组+链表+红黑树），桶中的结构可能是链表，也可能是红黑树，红黑树的引入是为了提高效率。
</code></pre><h2 id="内部结构"><a href="#内部结构" class="headerlink" title="内部结构"></a>内部结构</h2><h3 id="类的继承及属性"><a href="#类的继承及属性" class="headerlink" title="类的继承及属性"></a>类的继承及属性</h3><ul>
<li>查看HashMap源代码，可以发现其继承自AbstractMap, 并实现了Map, Cloneable, Serializable接口。<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">HashMap</span>&lt;<span class="title">K</span>,<span class="title">V</span>&gt; <span class="keyword">extends</span> <span class="title">AbstractMap</span>&lt;<span class="title">K</span>,<span class="title">V</span>&gt; <span class="keyword">implements</span> <span class="title">Map</span>&lt;<span class="title">K</span>,<span class="title">V</span>&gt;, <span class="title">Cloneable</span>, <span class="title">Serializable</span> </span>&#123;</span><br><span class="line">    <span class="comment">// 序列号</span></span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">long</span> serialVersionUID = <span class="number">362498820763181265L</span>;    </span><br><span class="line">    <span class="comment">// 默认的初始容量是16</span></span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> DEFAULT_INITIAL_CAPACITY = <span class="number">1</span> &lt;&lt; <span class="number">4</span>;   </span><br><span class="line">    <span class="comment">// 最大容量</span></span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> MAXIMUM_CAPACITY = <span class="number">1</span> &lt;&lt; <span class="number">30</span>; </span><br><span class="line">    <span class="comment">// 默认的填充因子</span></span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">float</span> DEFAULT_LOAD_FACTOR = <span class="number">0.75f</span>;</span><br><span class="line">    <span class="comment">// 当桶(bucket)上的结点数大于这个值时会转成红黑树</span></span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> TREEIFY_THRESHOLD = <span class="number">8</span>; </span><br><span class="line">    <span class="comment">// 当桶(bucket)上的结点数小于这个值时树转链表</span></span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> UNTREEIFY_THRESHOLD = <span class="number">6</span>;</span><br><span class="line">    <span class="comment">// 桶中结构转化为红黑树对应的table的最小大小</span></span><br><span class="line">    <span class="keyword">static</span> <span class="keyword">final</span> <span class="keyword">int</span> MIN_TREEIFY_CAPACITY = <span class="number">64</span>;</span><br><span class="line">    <span class="comment">// 存储元素的数组，总是2的幂次倍</span></span><br><span class="line">    <span class="keyword">transient</span> Node&lt;k,v&gt;[] table; </span><br><span class="line">    <span class="comment">// 存放具体元素的集</span></span><br><span class="line">    <span class="keyword">transient</span> Set&lt;map.entry&lt;k,v&gt;&gt; entrySet;</span><br><span class="line">    <span class="comment">// 存放元素的个数，注意这个不等于数组的长度。</span></span><br><span class="line">    <span class="keyword">transient</span> <span class="keyword">int</span> size;</span><br><span class="line">    <span class="comment">// 每次扩容和更改map结构的计数器</span></span><br><span class="line">    <span class="keyword">transient</span> <span class="keyword">int</span> modCount;   </span><br><span class="line">    <span class="comment">// 临界值 当实际大小(容量*填充因子)超过临界值时，会进行扩容</span></span><br><span class="line">    <span class="keyword">int</span> threshold;</span><br><span class="line">    <span class="comment">// 填充因子</span></span><br><span class="line">    <span class="keyword">final</span> <span class="keyword">float</span> loadFactor;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h3 id="构造函数"><a href="#构造函数" class="headerlink" title="构造函数"></a>构造函数</h3><ul>
<li>HashMap(int, float)构造函数<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="title">HashMap</span><span class="params">(<span class="keyword">int</span> initialCapacity, <span class="keyword">float</span> loadFactor)</span> </span>&#123;</span><br><span class="line">       <span class="comment">//初始化容量不能小于0，否则抛出IllegalArgumentException异常</span></span><br><span class="line">       <span class="keyword">if</span> (initialCapacity &lt; <span class="number">0</span>)</span><br><span class="line">           <span class="keyword">throw</span> <span class="keyword">new</span> IllegalArgumentException(<span class="string">"Illegal initial capacity: "</span> +</span><br><span class="line">                   initialCapacity);</span><br><span class="line">       <span class="comment">//初始化容量不能大于最大值，如果大于则为最大值</span></span><br><span class="line">       <span class="keyword">if</span> (initialCapacity &gt; MAXIMUM_CAPACITY)</span><br><span class="line">           initialCapacity = MAXIMUM_CAPACITY;</span><br><span class="line">       <span class="comment">//填充因子不能小于或者等于0，不能为非数字</span></span><br><span class="line">       <span class="keyword">if</span> (loadFactor &lt;= <span class="number">0</span> || Float.isNaN(loadFactor))</span><br><span class="line">           <span class="keyword">throw</span> <span class="keyword">new</span> IllegalArgumentException(<span class="string">"Illegal load factor: "</span> +</span><br><span class="line">                   loadFactor);</span><br><span class="line">       <span class="comment">//初始化填充因子</span></span><br><span class="line">       <span class="keyword">this</span>.loadFactor = loadFactor;</span><br><span class="line">       <span class="comment">//初始化临界值</span></span><br><span class="line">       <span class="keyword">this</span>.threshold = tableSizeFor(initialCapacity);</span><br><span class="line">   &#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p>说明一下：tableSizeFor(initialCapacity)返回值大于initialCapacity的最小的二次幂数值。<br><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br></pre></td><td class="code"><pre><span class="line">static final int tableSizeFor(int cap) &#123;</span><br><span class="line">        int n = cap - 1;</span><br><span class="line">        n |= n &gt;&gt;&gt; 1;</span><br><span class="line">        n |= n &gt;&gt;&gt; 2;</span><br><span class="line">        n |= n &gt;&gt;&gt; 4;</span><br><span class="line">        n |= n &gt;&gt;&gt; 8;</span><br><span class="line">        n |= n &gt;&gt;&gt; 16;</span><br><span class="line">        return (n &lt; 0) ? 1 : (n &gt;= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1;</span><br><span class="line">    &#125;</span><br><span class="line">``` </span><br><span class="line">-  HashMap(int)构造函数</span><br><span class="line">``` java</span><br><span class="line">	public HashMap(int initialCapacity) &#123;</span><br><span class="line">        //调用HashMap(int, float)构造函数,设置默认填充因子</span><br><span class="line">        this(initialCapacity, DEFAULT_LOAD_FACTOR);</span><br><span class="line">    &#125;</span><br><span class="line">``` </span><br><span class="line">-  HashMap()构造函数</span><br><span class="line">``` java</span><br><span class="line">	public HashMap() &#123;</span><br><span class="line">        //初始化填充因子,其他属性都用默认值</span><br><span class="line">        this.loadFactor = DEFAULT_LOAD_FACTOR; </span><br><span class="line">    &#125;</span><br><span class="line">``` </span><br><span class="line">- HashMap(Map&lt;? extends K&gt;)构造函数</span><br><span class="line">``` java</span><br><span class="line">	public HashMap(Map&lt;? extends K, ? extends V&gt; m) &#123;</span><br><span class="line">        //初始化填充因子值</span><br><span class="line">        this.loadFactor = DEFAULT_LOAD_FACTOR;</span><br><span class="line">        //将m中的所有元素添加至HashMap中</span><br><span class="line">        putMapEntries(m, false);</span><br><span class="line">    &#125;</span><br><span class="line">``` </span><br><span class="line">说明一下：putMapEntries(Map&lt;? extends K, ? extends V&gt; m, boolean evict)函数将m的所有元素存入本HashMap实例中</span><br><span class="line">``` java</span><br><span class="line">	final void putMapEntries(Map&lt;? extends K, ? extends V&gt; m, boolean evict) &#123;</span><br><span class="line">        int s = m.size();</span><br><span class="line">        if (s &gt; 0) &#123;</span><br><span class="line">            // 判断table是否为null</span><br><span class="line">            if (table == null) &#123; // pre-size</span><br><span class="line">                //等于null的时候，s为m的实际元素个数</span><br><span class="line">                float ft = ((float)s / loadFactor) + 1.0F;</span><br><span class="line">                int t = ((ft &lt; (float)MAXIMUM_CAPACITY) ?</span><br><span class="line">                        (int)ft : MAXIMUM_CAPACITY);</span><br><span class="line">                //计算得到的t大于阈值，则初始化阈值</span><br><span class="line">                if (t &gt; threshold)</span><br><span class="line">                    threshold = tableSizeFor(t);</span><br><span class="line">            &#125;</span><br><span class="line">            //不为null的时候，并且m的元素个数大于阈值，进行扩容处理</span><br><span class="line">            else if (s &gt; threshold)</span><br><span class="line">                resize();</span><br><span class="line">            //将m中的元素添加至HashMap中</span><br><span class="line">            for (Map.Entry&lt;? extends K, ? extends V&gt; e : m.entrySet()) &#123;</span><br><span class="line">                K key = e.getKey();</span><br><span class="line">                V value = e.getValue();</span><br><span class="line">                putVal(hash(key), key, value, false, evict);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">``` </span><br><span class="line"></span><br><span class="line">### 内部类</span><br><span class="line">HashMap包含一个数组对象table[]</span><br><span class="line">``` java</span><br><span class="line">    transient Node&lt;K,V&gt;[] table;</span><br></pre></td></tr></table></figure></p>
<p>数组中包含的元素为Node对象，Node是HashMap中定义的静态内部类，内容如下：</p>
<pre><code class="java"><span class="keyword">static</span> <span class="class"><span class="keyword">class</span> <span class="title">Node</span>&lt;<span class="title">K</span>,<span class="title">V</span>&gt; <span class="keyword">implements</span> <span class="title">Map</span>.<span class="title">Entry</span>&lt;<span class="title">K</span>,<span class="title">V</span>&gt; </span>{
    <span class="comment">//哈希</span>
    <span class="keyword">final</span> <span class="keyword">int</span> hash;
    <span class="comment">//键</span>
    <span class="keyword">final</span> K key;
    <span class="comment">//值</span>
    V value;
    <span class="comment">//下一个Node对象</span>
    Node&lt;K,V&gt; next;

    Node(<span class="keyword">int</span> hash, K key, V value, Node&lt;K,V&gt; next) {
        <span class="keyword">this</span>.hash = hash;
        <span class="keyword">this</span>.key = key;
        <span class="keyword">this</span>.value = value;
        <span class="keyword">this</span>.next = next;
    }

    <span class="function"><span class="keyword">public</span> <span class="keyword">final</span> K <span class="title">getKey</span><span class="params">()</span>        </span>{ <span class="keyword">return</span> key; }
    <span class="function"><span class="keyword">public</span> <span class="keyword">final</span> V <span class="title">getValue</span><span class="params">()</span>      </span>{ <span class="keyword">return</span> value; }
    <span class="function"><span class="keyword">public</span> <span class="keyword">final</span> String <span class="title">toString</span><span class="params">()</span> </span>{ <span class="keyword">return</span> key + <span class="string">"="</span> + value; }

    <span class="function"><span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">int</span> <span class="title">hashCode</span><span class="params">()</span> </span>{
        <span class="keyword">return</span> Objects.hashCode(key) ^ Objects.hashCode(value);
    }

    <span class="function"><span class="keyword">public</span> <span class="keyword">final</span> V <span class="title">setValue</span><span class="params">(V newValue)</span> </span>{
        V oldValue = value;
        value = newValue;
        <span class="keyword">return</span> oldValue;
    }

    <span class="function"><span class="keyword">public</span> <span class="keyword">final</span> <span class="keyword">boolean</span> <span class="title">equals</span><span class="params">(Object o)</span> </span>{
        <span class="keyword">if</span> (o == <span class="keyword">this</span>)
            <span class="keyword">return</span> <span class="keyword">true</span>;
        <span class="keyword">if</span> (o <span class="keyword">instanceof</span> Map.Entry) {
            Map.Entry&lt;?,?&gt; e = (Map.Entry&lt;?,?&gt;)o;
            <span class="keyword">if</span> (Objects.equals(key, e.getKey()) &amp;&amp;
                Objects.equals(value, e.getValue()))
                <span class="keyword">return</span> <span class="keyword">true</span>;
        }
        <span class="keyword">return</span> <span class="keyword">false</span>;
    }
}
</code></pre>
<p>##常用方法</p>
<h3 id="方法put实现"><a href="#方法put实现" class="headerlink" title="方法put实现"></a>方法put实现</h3><pre><code class="java"><span class="function"><span class="keyword">public</span> V <span class="title">put</span><span class="params">(K key, V value)</span> </span>{
    <span class="keyword">return</span> putVal(hash(key), key, value, <span class="keyword">false</span>, <span class="keyword">true</span>);
}
</code></pre>
<p>说明一下：HashMap中put方法真正插入逻辑是在putVal中实现的，下面看下putVal具体逻辑。</p>
<pre><code class="java">    <span class="function"><span class="keyword">final</span> V <span class="title">putVal</span><span class="params">(<span class="keyword">int</span> hash, K key, V value, <span class="keyword">boolean</span> onlyIfAbsent,
                   <span class="keyword">boolean</span> evict)</span> </span>{
    Node&lt;K,V&gt;[] tab; Node&lt;K,V&gt; p; <span class="keyword">int</span> n, i;
    <span class="comment">// table未初始化或者长度为0，进行扩容</span>
    <span class="keyword">if</span> ((tab = table) == <span class="keyword">null</span> || (n = tab.length) == <span class="number">0</span>)
        n = (tab = resize()).length;
    <span class="comment">// (n - 1) &amp; hash 确定元素存放在哪个桶中，桶为空，新生成结点放入桶中(此时，这个结点是放在数组中)</span>
    <span class="keyword">if</span> ((p = tab[i = (n - <span class="number">1</span>) &amp; hash]) == <span class="keyword">null</span>)
        tab[i] = newNode(hash, key, value, <span class="keyword">null</span>);
    <span class="comment">// 桶中已经存在元素</span>
    <span class="keyword">else</span> {
        Node&lt;K,V&gt; e; K k;
        <span class="comment">// 比较桶中第一个元素(数组中的结点)的hash值相等，key相等</span>
        <span class="keyword">if</span> (p.hash == hash &amp;&amp;
            ((k = p.key) == key || (key != <span class="keyword">null</span> &amp;&amp; key.equals(k))))
                <span class="comment">// 将第一个元素赋值给e，用e来记录</span>
                e = p;
        <span class="comment">// hash值不相等，即key不相等；为红黑树结点</span>
        <span class="keyword">else</span> <span class="keyword">if</span> (p <span class="keyword">instanceof</span> TreeNode)
            <span class="comment">// 放入树中</span>
            e = ((TreeNode&lt;K,V&gt;)p).putTreeVal(<span class="keyword">this</span>, tab, hash, key, value);
        <span class="comment">// 为链表结点</span>
        <span class="keyword">else</span> {
            <span class="comment">// 在链表最末插入结点</span>
            <span class="keyword">for</span> (<span class="keyword">int</span> binCount = <span class="number">0</span>; ; ++binCount) {
                <span class="comment">// 到达链表的尾部</span>
                <span class="keyword">if</span> ((e = p.next) == <span class="keyword">null</span>) {
                    <span class="comment">// 在尾部插入新结点</span>
                    p.next = newNode(hash, key, value, <span class="keyword">null</span>);
                    <span class="comment">// 结点数量达到阈值，转化为红黑树</span>
                    <span class="keyword">if</span> (binCount &gt;= TREEIFY_THRESHOLD - <span class="number">1</span>) <span class="comment">// -1 for 1st</span>
                        treeifyBin(tab, hash);
                    <span class="comment">// 跳出循环</span>
                    <span class="keyword">break</span>;
                }
                <span class="comment">// 判断链表中结点的key值与插入的元素的key值是否相等</span>
                <span class="keyword">if</span> (e.hash == hash &amp;&amp;
                    ((k = e.key) == key || (key != <span class="keyword">null</span> &amp;&amp; key.equals(k))))
                    <span class="comment">// 相等，跳出循环</span>
                    <span class="keyword">break</span>;
                <span class="comment">// 用于遍历桶中的链表，与前面的e = p.next组合，可以遍历链表</span>
                p = e;
            }
        }
        <span class="comment">// 表示在桶中找到key值、hash值与插入元素相等的结点</span>
        <span class="keyword">if</span> (e != <span class="keyword">null</span>) { 
            <span class="comment">// 记录e的value</span>
            V oldValue = e.value;
            <span class="comment">// onlyIfAbsent为false或者旧值为null</span>
            <span class="keyword">if</span> (!onlyIfAbsent || oldValue == <span class="keyword">null</span>)
                <span class="comment">//用新值替换旧值</span>
                e.value = value;
            <span class="comment">// 访问后回调</span>
            afterNodeAccess(e);
            <span class="comment">// 返回旧值</span>
            <span class="keyword">return</span> oldValue;
        }
    }
    <span class="comment">// 结构性修改</span>
    ++modCount;
    <span class="comment">// 实际大小大于阈值则扩容</span>
    <span class="keyword">if</span> (++size &gt; threshold)
        resize();
    <span class="comment">// 插入后回调</span>
    afterNodeInsertion(evict);
    <span class="keyword">return</span> <span class="keyword">null</span>;
}
</code></pre>
<h3 id="方法get实现"><a href="#方法get实现" class="headerlink" title="方法get实现"></a>方法get实现</h3><pre><code class="java"><span class="function"><span class="keyword">public</span> V <span class="title">get</span><span class="params">(Object key)</span> </span>{
    Node&lt;K,V&gt; e;
    <span class="keyword">return</span> (e = getNode(hash(key), key)) == <span class="keyword">null</span> ? <span class="keyword">null</span> : e.value;
}
</code></pre>
<p>说明一下：HashMap中get方法真正获取逻辑是在getNode中实现的，下面看下getNode具体逻辑。</p>
<pre><code class="java">    <span class="function"><span class="keyword">final</span> Node&lt;K,V&gt; <span class="title">getNode</span><span class="params">(<span class="keyword">int</span> hash, Object key)</span> </span>{
    Node&lt;K,V&gt;[] tab; Node&lt;K,V&gt; first, e; <span class="keyword">int</span> n; K k;
    <span class="comment">// table已经初始化，长度大于0，根据hash寻找table中的项也不为空</span>
    <span class="keyword">if</span> ((tab = table) != <span class="keyword">null</span> &amp;&amp; (n = tab.length) &gt; <span class="number">0</span> &amp;&amp;
        (first = tab[(n - <span class="number">1</span>) &amp; hash]) != <span class="keyword">null</span>) {
        <span class="comment">// 桶中第一项(数组元素)相等</span>
        <span class="keyword">if</span> (first.hash == hash &amp;&amp; <span class="comment">// always check first node</span>
            ((k = first.key) == key || (key != <span class="keyword">null</span> &amp;&amp; key.equals(k))))
            <span class="keyword">return</span> first;
        <span class="comment">// 桶中不止一个结点</span>
        <span class="keyword">if</span> ((e = first.next) != <span class="keyword">null</span>) {
            <span class="comment">// 为红黑树结点</span>
            <span class="keyword">if</span> (first <span class="keyword">instanceof</span> TreeNode)
                <span class="comment">// 在红黑树中查找</span>
                <span class="keyword">return</span> ((TreeNode&lt;K,V&gt;)first).getTreeNode(hash, key);
            <span class="comment">// 否则，在链表中查找</span>
            do {
                <span class="keyword">if</span> (e.hash == hash &amp;&amp;
                    ((k = e.key) == key || (key != <span class="keyword">null</span> &amp;&amp; key.equals(k))))
                    <span class="keyword">return</span> e;
            } <span class="keyword">while</span> ((e = e.next) != <span class="keyword">null</span>);
        }
    }
    <span class="keyword">return</span> <span class="keyword">null</span>;
}
</code></pre>
<h3 id="方法clear实现"><a href="#方法clear实现" class="headerlink" title="方法clear实现"></a>方法clear实现</h3><pre><code class="java"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">clear</span><span class="params">()</span> </span>{
    Node&lt;K,V&gt;[] tab;
    <span class="comment">//计数器加1操作</span>
    modCount++;
    <span class="keyword">if</span> ((tab = table) != <span class="keyword">null</span> &amp;&amp; size &gt; <span class="number">0</span>) {
        <span class="comment">//个数设置为0</span>
        size = <span class="number">0</span>;
        <span class="comment">//数组中元素设置为null</span>
        <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; tab.length; ++i)
            tab[i] = <span class="keyword">null</span>;
    }
}
</code></pre>
<h3 id="方法resize实现"><a href="#方法resize实现" class="headerlink" title="方法resize实现"></a>方法resize实现</h3><pre><code class="java">    <span class="keyword">final</span> Node&lt;K,V&gt;[] resize() {
    <span class="comment">// 当前table保存</span>
    Node&lt;K,V&gt;[] oldTab = table;
    <span class="comment">// 保存table大小</span>
    <span class="keyword">int</span> oldCap = (oldTab == <span class="keyword">null</span>) ? <span class="number">0</span> : oldTab.length;
    <span class="comment">// 保存当前阈值 </span>
    <span class="keyword">int</span> oldThr = threshold;
    <span class="keyword">int</span> newCap, newThr = <span class="number">0</span>;
    <span class="comment">// 之前table大小大于0</span>
    <span class="keyword">if</span> (oldCap &gt; <span class="number">0</span>) {
        <span class="comment">// 之前table大于最大容量</span>
        <span class="keyword">if</span> (oldCap &gt;= MAXIMUM_CAPACITY) {
            <span class="comment">// 阈值为最大整形</span>
            threshold = Integer.MAX_VALUE;
            <span class="keyword">return</span> oldTab;
        }
        <span class="comment">// 容量翻倍，使用左移，效率更高</span>
        <span class="keyword">else</span> <span class="keyword">if</span> ((newCap = oldCap &lt;&lt; <span class="number">1</span>) &lt; MAXIMUM_CAPACITY &amp;&amp;
            oldCap &gt;= DEFAULT_INITIAL_CAPACITY)
            <span class="comment">// 阈值翻倍</span>
            newThr = oldThr &lt;&lt; <span class="number">1</span>; <span class="comment">// double threshold</span>
    }
    <span class="comment">// 之前阈值大于0</span>
    <span class="keyword">else</span> <span class="keyword">if</span> (oldThr &gt; <span class="number">0</span>)
        newCap = oldThr;
    <span class="comment">// oldCap = 0并且oldThr = 0，使用缺省值（如使用HashMap()构造函数，之后再插入一个元素会调用resize函数，会进入这一步）</span>
    <span class="keyword">else</span> {           
        newCap = DEFAULT_INITIAL_CAPACITY;
        newThr = (<span class="keyword">int</span>)(DEFAULT_LOAD_FACTOR * DEFAULT_INITIAL_CAPACITY);
    }
    <span class="comment">// 新阈值为0</span>
    <span class="keyword">if</span> (newThr == <span class="number">0</span>) {
        <span class="keyword">float</span> ft = (<span class="keyword">float</span>)newCap * loadFactor;
        newThr = (newCap &lt; MAXIMUM_CAPACITY &amp;&amp; ft &lt; (<span class="keyword">float</span>)MAXIMUM_CAPACITY ?
                  (<span class="keyword">int</span>)ft : Integer.MAX_VALUE);
    }
    threshold = newThr;
    <span class="meta">@SuppressWarnings</span>({<span class="string">"rawtypes"</span>,<span class="string">"unchecked"</span>})
    <span class="comment">// 初始化table</span>
    Node&lt;K,V&gt;[] newTab = (Node&lt;K,V&gt;[])<span class="keyword">new</span> Node[newCap];
    table = newTab;
    <span class="comment">// 之前的table已经初始化过</span>
    <span class="keyword">if</span> (oldTab != <span class="keyword">null</span>) {
        <span class="comment">// 复制元素，重新进行hash</span>
        <span class="keyword">for</span> (<span class="keyword">int</span> j = <span class="number">0</span>; j &lt; oldCap; ++j) {
            Node&lt;K,V&gt; e;
            <span class="keyword">if</span> ((e = oldTab[j]) != <span class="keyword">null</span>) {
                oldTab[j] = <span class="keyword">null</span>;
                <span class="keyword">if</span> (e.next == <span class="keyword">null</span>)
                    newTab[e.hash &amp; (newCap - <span class="number">1</span>)] = e;
                <span class="keyword">else</span> <span class="keyword">if</span> (e <span class="keyword">instanceof</span> TreeNode)
                    ((TreeNode&lt;K,V&gt;)e).split(<span class="keyword">this</span>, newTab, j, oldCap);
                <span class="keyword">else</span> { <span class="comment">// preserve order</span>
                    Node&lt;K,V&gt; loHead = <span class="keyword">null</span>, loTail = <span class="keyword">null</span>;
                    Node&lt;K,V&gt; hiHead = <span class="keyword">null</span>, hiTail = <span class="keyword">null</span>;
                    Node&lt;K,V&gt; next;
                    <span class="comment">// 将同一桶中的元素根据(e.hash &amp; oldCap)是否为0进行分割，分成两个不同的链表，完成rehash</span>
                    do {
                        next = e.next;
                        <span class="keyword">if</span> ((e.hash &amp; oldCap) == <span class="number">0</span>) {
                            <span class="keyword">if</span> (loTail == <span class="keyword">null</span>)
                                loHead = e;
                            <span class="keyword">else</span>
                                loTail.next = e;
                            loTail = e;
                        }
                        <span class="keyword">else</span> {
                            <span class="keyword">if</span> (hiTail == <span class="keyword">null</span>)
                                hiHead = e;
                            <span class="keyword">else</span>
                                hiTail.next = e;
                            hiTail = e;
                        }
                    } <span class="keyword">while</span> ((e = next) != <span class="keyword">null</span>);
                    <span class="keyword">if</span> (loTail != <span class="keyword">null</span>) {
                        loTail.next = <span class="keyword">null</span>;
                        newTab[j] = loHead;
                    }
                    <span class="keyword">if</span> (hiTail != <span class="keyword">null</span>) {
                        hiTail.next = <span class="keyword">null</span>;
                        newTab[j + oldCap] = hiHead;
                    }
                }
            }
        }
    }
    <span class="keyword">return</span> newTab;
}
</code></pre>
<p>说明一下：如果HashMap中添加元素超过了阈值，则需要扩容，并重新分配元素到新的数组，并且会遍历hash表中所有的元素，是非常耗时的。在编写程序中，要尽量避免resize。</p>
<h2 id="小结一下"><a href="#小结一下" class="headerlink" title="小结一下"></a>小结一下</h2><p>使用一个Node数组来存储数据，但这个Node可能是链表结构，也可能是红黑树结构。<br>如果插入的key的hashcode相同，那么这些key也会被定位到Node数组的同一个格子里。<br>如果同一个格子里的key不超过8个，使用链表结构存储。<br>如果超过了8个，那么会调用treeifyBin函数，将链表转换为红黑树。</p>
<h2 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h2><p>1.<a href="http://www.cnblogs.com/leesf456/p/5242233.html" target="_blank" rel="external">http://www.cnblogs.com/leesf456/p/5242233.html</a><br>2.<a href="http://www.cnblogs.com/stevenczp/p/7028071.html" target="_blank" rel="external">http://www.cnblogs.com/stevenczp/p/7028071.html</a><br>3.<a href="https://tech.meituan.com/java-hashmap.html" target="_blank" rel="external">https://tech.meituan.com/java-hashmap.html</a><br>4.<a href="https://my.oschina.net/wangmengjun/blog/1527300" target="_blank" rel="external">https://my.oschina.net/wangmengjun/blog/1527300</a></p>

      
    </div>
    
    <div class="article-info article-info-index">
      
      
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/java/">java</a>
    </div>


      
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/HashMap/">HashMap</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/java/">java</a></li></ul>
    </div>

      
      <div class="clearfix"></div>
    </div>
    
  </div>
  
</article>









  
    <article id="post-java/rbac/RBAC" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2017/09/01/java/rbac/RBAC/" class="article-date">
      <time datetime="2017-09-01T14:27:11.000Z" itemprop="datePublished">2017-09-01</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2017/09/01/java/rbac/RBAC/">RBAC</a>
    </h1>
  

      </header>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <h1 id="RBAC介绍"><a href="#RBAC介绍" class="headerlink" title="RBAC介绍"></a>RBAC介绍</h1><h2 id="一、RBAC简介"><a href="#一、RBAC简介" class="headerlink" title="一、RBAC简介"></a>一、RBAC简介</h2><p><strong>RBAC</strong>(<code>Role-Based Access Control</code>)是基于角色的访问控制,在RBAC中，权限与角色进行关联，用户通过成为不同的角色成员，从而用于相对应的角色权限。</p>
<h2 id="二、RBAC介绍"><a href="#二、RBAC介绍" class="headerlink" title="二、RBAC介绍"></a>二、RBAC介绍</h2><p><strong>RBAC</strong>简单点说，就是<code>WHO</code>,<code>WHAT</code>,<code>HOW</code>三组数据之间关联关系（可能它们之间擦出某种火花），然后由<code>WHO</code>对<code>WHAT</code>进行了<code>HOW</code>的操作。</p>
<h5 id="WHO：权限的拥有者或主体"><a href="#WHO：权限的拥有者或主体" class="headerlink" title="WHO：权限的拥有者或主体"></a><code>WHO</code>：权限的拥有者或主体</h5><h5 id="WHAT：权限针对的对象或资源"><a href="#WHAT：权限针对的对象或资源" class="headerlink" title="WHAT：权限针对的对象或资源"></a><code>WHAT</code>：权限针对的对象或资源</h5><h5 id="HOW：具体的权限"><a href="#HOW：具体的权限" class="headerlink" title="HOW：具体的权限"></a><code>HOW</code>：具体的权限</h5><blockquote>
<p>参见详细的介绍：<a href="http://baike.baidu.com/item/RBAC?fr=aladdin" target="_blank" rel="external">百度百科</a> ,<a href="https://zh.wikipedia.org/zh-cn/%E4%BB%A5%E8%A7%92%E8%89%B2%E7%82%BA%E5%9F%BA%E7%A4%8E%E7%9A%84%E5%AD%98%E5%8F%96%E6%8E%A7%E5%88%B6" target="_blank" rel="external">维基百科</a></p>
</blockquote>
<h2 id="三、RBAC分类"><a href="#三、RBAC分类" class="headerlink" title="三、RBAC分类"></a>三、RBAC分类</h2><h5 id="RBAC0-组成部分【1-用户-User-，2-角色-Role-，3-许可-Pemission-，4-会话-Session-】"><a href="#RBAC0-组成部分【1-用户-User-，2-角色-Role-，3-许可-Pemission-，4-会话-Session-】" class="headerlink" title="RBAC0:组成部分【1.用户(User)，2.角色(Role)，3.许可(Pemission)，4.会话(Session)】"></a>RBAC0:组成部分【1.用户(User)，2.角色(Role)，3.许可(Pemission)，4.会话(Session)】</h5><h5 id="RBAC1-引入了角色继承概念，从而有了上下级的包含关系"><a href="#RBAC1-引入了角色继承概念，从而有了上下级的包含关系" class="headerlink" title="RBAC1:引入了角色继承概念，从而有了上下级的包含关系"></a>RBAC1:引入了角色继承概念，从而有了上下级的包含关系</h5><h5 id="RBAC2-引入SSD-讲台职责分离-和DSD-动态职责分离"><a href="#RBAC2-引入SSD-讲台职责分离-和DSD-动态职责分离" class="headerlink" title="RBAC2:引入SSD(讲台职责分离)和DSD(动态职责分离)"></a>RBAC2:引入SSD(讲台职责分离)和DSD(动态职责分离)</h5><h5 id="RBAC3-RBAC2-RBAC1"><a href="#RBAC3-RBAC2-RBAC1" class="headerlink" title="RBAC3:RBAC2+ RBAC1"></a>RBAC3:RBAC2+ RBAC1</h5><blockquote>
<p>总结：</p>
<h5 id="RBAC0-RBAC的核心思想"><a href="#RBAC0-RBAC的核心思想" class="headerlink" title="RBAC0:RBAC的核心思想"></a>RBAC0:RBAC的核心思想</h5><h5 id="RBAC1-将角色分层模型"><a href="#RBAC1-将角色分层模型" class="headerlink" title="RBAC1:将角色分层模型"></a>RBAC1:将角色分层模型</h5><h5 id="RBAC2-增加约束模型"><a href="#RBAC2-增加约束模型" class="headerlink" title="RBAC2:增加约束模型"></a>RBAC2:增加约束模型</h5><h5 id="RBAC3-RBAC2-RBAC1-1"><a href="#RBAC3-RBAC2-RBAC1-1" class="headerlink" title="RBAC3: RBAC2+ RBAC1"></a>RBAC3: RBAC2+ RBAC1</h5><h2 id="四、完整设计图"><a href="#四、完整设计图" class="headerlink" title="四、完整设计图"></a>四、完整设计图</h2><p><img src="/2017/09/01/java/rbac/RBAC/RBAC.png" alt=""></p>
</blockquote>

      
    </div>
    
    <div class="article-info article-info-index">
      
      
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/java/">java</a>
    </div>


      
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/RBAC/">RBAC</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/java/">java</a></li></ul>
    </div>

      
      <div class="clearfix"></div>
    </div>
    
  </div>
  
</article>









  
    <article id="post-about" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2017/09/01/about/" class="article-date">
      <time datetime="2017-09-01T14:24:32.000Z" itemprop="datePublished">2017-09-01</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2017/09/01/about/">关于我</a>
    </h1>
  

      </header>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <h1 id="关于我"><a href="#关于我" class="headerlink" title="关于我"></a>关于我</h1><pre><code>I am a coder.
1992年生，已婚，有一闺女，坐标江苏苏州，平日没事看看书，逛逛技术博客。
总结一下：像个傻瓜一样痴迷于技术。
</code></pre><h1 id="联系方式"><a href="#联系方式" class="headerlink" title="联系方式"></a>联系方式</h1><pre><code>QQ：909442787
微信：zte_cly
邮箱：ztelovecly@gmail.com
</code></pre><h1 id="工作经历"><a href="#工作经历" class="headerlink" title="工作经历"></a>工作经历</h1><pre><code>2014.11-2015.06  创元期货股份有限公司
2015.07-2017.03  苏州犀牛网络科技有限公司
2017.04-至今      江苏筑牛网络科技有限公司
</code></pre>
      
    </div>
    
    <div class="article-info article-info-index">
      
      
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/关于我/">关于我</a>
    </div>


      
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/关于我/">关于我</a></li></ul>
    </div>

      
      <div class="clearfix"></div>
    </div>
    
  </div>
  
</article>









  
    <article id="post-阅读笔记/实践Java虚拟机-JVM故障诊断与性能优化" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2017/09/01/阅读笔记/实践Java虚拟机-JVM故障诊断与性能优化/" class="article-date">
      <time datetime="2017-09-01T14:07:51.000Z" itemprop="datePublished">2017-09-01</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2017/09/01/阅读笔记/实践Java虚拟机-JVM故障诊断与性能优化/">《实践Java虚拟机-JVM故障诊断与性能优化》阅读笔记</a>
    </h1>
  

      </header>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <pre><code>待完善
</code></pre>
      
    </div>
    
    <div class="article-info article-info-index">
      
      
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/java/">java</a>
    </div>


      
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/java/">java</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/jvm/">jvm</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/实践Java虚拟机-JVM故障诊断与性能优化/">实践Java虚拟机-JVM故障诊断与性能优化</a></li></ul>
    </div>

      
      <div class="clearfix"></div>
    </div>
    
  </div>
  
</article>









  
    <article id="post-阅读笔记/Linux私房菜-基础学习篇" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2017/09/01/阅读笔记/Linux私房菜-基础学习篇/" class="article-date">
      <time datetime="2017-09-01T14:07:51.000Z" itemprop="datePublished">2017-09-01</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2017/09/01/阅读笔记/Linux私房菜-基础学习篇/">《Linux私房菜-基础学习篇》阅读笔记</a>
    </h1>
  

      </header>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <pre><code>待完善
</code></pre>
      
    </div>
    
    <div class="article-info article-info-index">
      
      
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/linux/">linux</a>
    </div>


      
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Linux私房菜-基础学习篇/">Linux私房菜-基础学习篇</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/linux/">linux</a></li></ul>
    </div>

      
      <div class="clearfix"></div>
    </div>
    
  </div>
  
</article>









  
    <article id="post-阅读笔记/大数据之路-阿里巴巴大数据实践" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2017/09/01/阅读笔记/大数据之路-阿里巴巴大数据实践/" class="article-date">
      <time datetime="2017-09-01T14:07:51.000Z" itemprop="datePublished">2017-09-01</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2017/09/01/阅读笔记/大数据之路-阿里巴巴大数据实践/">《大数据之路》阅读笔记</a>
    </h1>
  

      </header>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <pre><code>待完善
</code></pre>
      
    </div>
    
    <div class="article-info article-info-index">
      
      
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/大数据/">大数据</a>
    </div>


      
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/java/">java</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/大数据/">大数据</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/大数据之路/">大数据之路</a></li></ul>
    </div>

      
      <div class="clearfix"></div>
    </div>
    
  </div>
  
</article>









  
    <article id="post-阅读笔记/Java核心技术-卷1" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2017/09/01/阅读笔记/Java核心技术-卷1/" class="article-date">
      <time datetime="2017-09-01T14:07:51.000Z" itemprop="datePublished">2017-09-01</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2017/09/01/阅读笔记/Java核心技术-卷1/">《Java核心技术-卷1》阅读笔记</a>
    </h1>
  

      </header>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <pre><code>待完善
</code></pre>
      
    </div>
    
    <div class="article-info article-info-index">
      
      
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/java/">java</a>
    </div>


      
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Java核心技术-卷1/">Java核心技术-卷1</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/java/">java</a></li></ul>
    </div>

      
      <div class="clearfix"></div>
    </div>
    
  </div>
  
</article>









  
    <article id="post-阅读笔记/Android系统源代码情景分析" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2017/09/01/阅读笔记/Android系统源代码情景分析/" class="article-date">
      <time datetime="2017-09-01T14:07:51.000Z" itemprop="datePublished">2017-09-01</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2017/09/01/阅读笔记/Android系统源代码情景分析/">《Android系统源代码情景分析》阅读笔记</a>
    </h1>
  

      </header>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <pre><code>待完善
</code></pre>
      
    </div>
    
    <div class="article-info article-info-index">
      
      
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/android/">android</a>
    </div>


      
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Android系统源代码情景分析/">Android系统源代码情景分析</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/android/">android</a></li></ul>
    </div>

      
      <div class="clearfix"></div>
    </div>
    
  </div>
  
</article>









  
    <article id="post-阅读笔记/Hadoop权威指南" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2017/09/01/阅读笔记/Hadoop权威指南/" class="article-date">
      <time datetime="2017-09-01T14:07:51.000Z" itemprop="datePublished">2017-09-01</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2017/09/01/阅读笔记/Hadoop权威指南/">《Hadoop权威指南》阅读笔记</a>
    </h1>
  

      </header>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <pre><code>待完善
</code></pre>
      
    </div>
    
    <div class="article-info article-info-index">
      
      
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/大数据/">大数据</a>
    </div>


      
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Hadoop权威指南/">Hadoop权威指南</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/java/">java</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/大数据/">大数据</a></li></ul>
    </div>

      
      <div class="clearfix"></div>
    </div>
    
  </div>
  
</article>









  
    <article id="post-阅读笔记/Java并发编程-核心方法与框架" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2017/09/01/阅读笔记/Java并发编程-核心方法与框架/" class="article-date">
      <time datetime="2017-09-01T14:07:51.000Z" itemprop="datePublished">2017-09-01</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/2017/09/01/阅读笔记/Java并发编程-核心方法与框架/">《Java并发编程-核心方法与框架》阅读笔记</a>
    </h1>
  

      </header>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <pre><code>待完善
</code></pre>
      
    </div>
    
    <div class="article-info article-info-index">
      
      
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/java/">java</a>
    </div>


      
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Java并发编程-核心方法与框架/">Java并发编程-核心方法与框架</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/java/">java</a></li></ul>
    </div>

      
      <div class="clearfix"></div>
    </div>
    
  </div>
  
</article>









  
  
    <nav id="page-nav">
      <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="page-number" href="/page/3/">3</a><a class="extend next" rel="next" href="/page/2/">Next &raquo;</a>
    </nav>
  
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                &copy; 2017 赵天恩
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank" title="快速、简洁且高效的博客框架">Hexo</a>  Theme <a href="https://github.com/MOxFIVE/hexo-theme-yelee" target="_blank" title="简而不减 Hexo 双栏博客主题">Yelee</a> by MOxFIVE
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" >本站到访数: 
                            <span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>, </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit">本页阅读量: 
                            <span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>
    </div>
    
<script data-main="/js/main.js" src="//cdn.bootcss.com/require.js/2.1.22/require.min.js"></script>

    <script>
        $(document).ready(function() {
            var iPad = window.navigator.userAgent.indexOf('iPad');
            if (iPad > -1 || $(".left-col").css("display") === "none") {
                var bgColorList = ["#9db3f4", "#414141", "#e5a859", "#f5dfc6", "#c084a0", "#847e72", "#cd8390", "#996731"];
                var bgColor = Math.ceil(Math.random() * (bgColorList.length - 1));
                $("body").css({"background-color": bgColorList[bgColor], "background-size": "cover"});
            }
            else {
                var backgroundnum = 5;
                var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
                $("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
            }
        })
    </script>




    <script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script src="//cdn.bootcss.com/mathjax/2.6.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


<div class="scroll" id="scroll">
    <a href="#" title="返回顶部"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments" title="查看评论"><i class="fa fa-comments-o"></i></a>
    <a href="#footer" title="转到底部"><i class="fa fa-arrow-down"></i></a>
</div>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
  </div>
</body>
</html>